/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function random_mypass(){
    new backend({
        url: base_url + 'so/user/randomstring',
        data: {},
        callback: function(rsdata) {
            if (rsdata.result < 0) {
                $.jGrowl(rsdata.message,{ sticky: true, theme: 'growl-error', header: 'Error!' });
            } else {
                $('#my_password').val(rsdata.message);
            }
        }
    }).call();
}
function update_me(){
    if($('#my_name').val()=='')return;
    new backend({
        url: base_url + 'so/user/update_me',
        data: {
            Params:{
                ause_name:$('#my_name').val(),
                ause_password:$('#my_password').val()
            }
        },
        callback: function(rsdata) {
            if (rsdata.result < 0) {
                $.jGrowl(rsdata.message,{ sticky: true, theme: 'growl-error', header: 'Error!' });
            } else {
                $.jGrowl(rsdata.message);
                $('#my_password').val('');
            }
        }
    }).call();
}
function dialog_user(){
    $('#dialog-user>.base-dialog-modal').html('<div class="base_loading" style="display: block;height: 60px"></div>');
    bckdialog({
        title:'My Profile',
        message:$('#dialog-user'),
        buttons: [
            {
                text    :'Save',
                class   :'base_button base_green base-small-border-radius',
                click   : function() {
                    update_me();
                }
            },
            {
                text    :'Close',
                class   :'base_button',
                click   : function() {
                    $(this).dialog("close");
                }
            }
        ]
    }).open();
    $('#dialog-user>.base-dialog-modal').load(base_url+ 'so/user/my_profile',function(){
        //$("#my_password").jqxPasswordInput({ theme: theme, width: '300px', height: '20px', showStrength: true, showStrengthPosition: "right" });
        $('#dialog-user').dialog("close").dialog("open");
        
    });
}
function dialog_notication(){
    $('#dialog-notications>.base-dialog-modal').html('<div class="base_loading" style="display: block;height: 60px"></div>');
    var _dialog = $('#dialog-notications');
    bckdialog({
        title:'Messages',
        message:$('#dialog-notications'),
        buttons: [
            {
                text    :'Refresh',
                class   :'base_button base_green base-small-border-radius',
                click   : function() {
                    _dialog.parents('.ui-dialog').find('.dialog-pending').show();
                    $('#dialog-notications>.base-dialog-modal').load('/backend/request/loadNewRequest',function(){
                        _dialog.parents('.ui-dialog').find('.dialog-pending').hide();
                        $('#dialog-notications').dialog('close').dialog('open'); 
                    });
                }
            },{
                text    :'Cancel',
                class   :'base_button base_red base-small-border-radius',
                click   : function() {
                    $(this).dialog("close");
                }
            }
        ]
    }).open();
    $('#dialog-notications>.base-dialog-modal').load(base_url + 'backend/request/loadNewRequest',function(){
        $('#dialog-notications').dialog('close').dialog('open'); 
    });
}
function see_message(that,Id){
    $(that).hide();
    $(that).parent().next().show();
    new backend({
        url: base_url + "backend/excution/commit/contact/contact/cont",
        data: {
            Id: Id,
            Params: {
                cont_delete:'2013-12-05 00:00:00'
            }
        },
        callback: function(rsdata) {
            PENDING = false;
        }
    }).call();
}
